package com.yonyou.brigade.third_parties.ctrip.bigcustomer.controller;

import com.alibaba.fastjson.JSONObject;
import com.yonyou.brigade.basic_init.enums.ChannelEnum;
import com.yonyou.brigade.basic_init.service.IBriChannelService;
import com.yonyou.brigade.third_parties.ctrip.bigcustomer.service.IBigCustomerService;
import com.yonyou.brigade.third_parties.ctrip.bigcustomer.util.CtripBigCustomerRMIUtils;
import com.yonyou.brigade.third_parties.ctrip.model.CtripConfig;
import com.yonyou.brigade.third_parties.ctrip.util.CtripUtil;
import com.yonyou.brigade.util.resultutil.Msg;
import com.yonyou.brigade.util.resultutil.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/thirdparties/ctrip/bigcustomer/home")
public class CtripBigCustomer {

    @Autowired
    @Qualifier("bigCustomerServiceImpl")
    private IBigCustomerService bigCustomerService;

    @Autowired
    @Qualifier("briChannelServiceImpl")
    private IBriChannelService briChannelService;

    private Logger logger=LoggerFactory.getLogger(CtripBigCustomer.class);

    @RequestMapping(value = "/open", method = RequestMethod.GET)
    public @ResponseBody
    Object open()
    {

        return ResultUtil.success("成功");
//        CtripConfig config=new CtripConfig();
//        return "a";
//        config.setAppKey(body.get("appKey").toString());
//        config.setAppSecurity(body.get("appSecurity").toString());
//        config.setCorporationId(body.get("corporationId").toString());
//        config.setSubAccountName(body.get("subAccountName").toString());
//        config.setType(ChannelEnum.CTRIPBC.getName());
//        String tenant=body.get("tenant").toString();
//        String orgPk=body.get("orgPk").toString();
//        int preApprove=Integer.parseInt(body.get("preApprove").toString());
//        String phone=body.get("phone").toString();
//        bigCustomerService.openCtripBigCustomer(tenant,orgPk,preApprove,phone,config);

    }
//
//    @RequestMapping(value = "/ssomobilectrip", method = RequestMethod.GET)
//    public void ssoMobileCtrip(String pcode, String tenantId,String orgPk, String initPage, HttpServletResponse response){
//
//            CtripConfig ctripConfig =(CtripConfig) briChannelService.getChannelConfig(tenantId,orgPk,ChannelEnum.CTRIPBC.getName(),new CtripConfig()) ;
//            int tokenType = 1;
//            try {
//                CtripBigCustomerRMIUtils.ssoMobileLogin(pcode, ctripConfig, initPage, tokenType,response);
//            }
//            catch (Exception e)
//            {
//                logger.error(e.getMessage());
//            }
//
//    }



}
